package com.itheima.mapper;

import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckGroupMapper {
    /**
     * 添加检查组
     * @param checkGroup
     */
    Integer insert(CheckGroup checkGroup);

    /**
     * 根据id删除检查组
     * @param id
     */
    @Delete("delete from check_group where id = #{id}")
    void deleteById(Integer id);

    /**
     * 根据名称查询检查组
     * @param name
     * @return
     */
    @Select("select id from check_group where name = #{name}")
    Integer selectByName(String name);

    /**
     * 修改检查组
     * @param checkGroup
     */
//    @Update("update check_group set code = #{code}, name = #{name}, help_code = #{helpCode}, sex = #{sex}," +
//            " remark = #{remark}, attention = #{attention} where id = #{id}")
    void update(CheckGroup checkGroup);

    /**
     * 根据id查询检查组
     * @param groupId
     * @return
     */
    @Select("select * from check_group where id = #{groupId}")
    CheckGroup selectById(Integer groupId);

    /**
     * 根据条件查询检查组
     * @param queryString
     * @return
     */
    @Select("select * from check_group " +
            "where name like concat('%',#{queryString},'%') or help_code like concat('%',#{queryString},'%')" +
            "or remark like concat('%',#{queryString},'%') or code=#{queryString}")
    List<CheckGroup> search(String queryString);
}
